home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 278_01 / cxldemo.c < prev   
C/C++ Source or Header  |  1990-02-13  |  47KB  |  1,448 lines

  1. /* ┌┬───────────────────────────────────────────────────────────────────┬┐
  2.    ││                                                                   ││
  3.    ││                     CXL Demonstration Program                     ││
  4.    ││                                                                   ││
  5.    ││              CXL is Copyright (c) 1987-1989 by Mike Smedley       ││
  6.    ││                                                                   ││
  7.    ││               Syntax:  CXLDEMO [-switches]                        ││
  8.    ││                                                                   ││
  9.    ││                        -c = CGA snow elimination                  ││
  10.    ││                        -b = BIOS screen writing                   ││
  11.    ││                        -m = force monochrome text attributes      ││
  12.    ││                                                                   ││
  13.    ││               Compiler command lines:                             ││
  14.    ││                                                                   ││
  15.    ││                MSC:    cl -Ox cxldemo.c cxlmss.lib                ││
  16.    ││                QC:     qcl -Ox cxldemo.c cxlmss.lib               ││
  17.    ││                TC:     tcc -Z -O cxldemo.c cxltcs.lib             ││
  18.    ││                ZTC:    ztc -msi -o -b cxldemo.c cxlzts.lib        ││
  19.    ││                                                                   ││
  20.    └┴───────────────────────────────────────────────────────────────────┴┘ */
  21.  
  22. /*---------------------------------------------------------------------------*/
  23.  
  24. /* header files */
  25. #include <conio.h>
  26. #include <ctype.h>
  27. #include <dos.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include "cxldef.h"
  32. #include "cxlkey.h"
  33. #include "cxlmou.h"
  34. #include "cxlstr.h"
  35. #include "cxlvid.h"
  36. #include "cxlwin.h"
  37.  
  38. #if defined(__TURBOC__)                             /* Turbo C */
  39.     #include <dir.h>
  40. #else
  41.     #include <direct.h>                             /* all others */
  42. #endif
  43.  
  44. #if defined(M_I86) && !defined(__ZTC__)             /* MSC/QuickC */
  45.     #define bioskey(a)       _bios_keybrd(a)
  46.     #define findfirst(a,b,c) _dos_findfirst(a,c,b)
  47.     #define findnext(a)      _dos_findnext(a)
  48.     #define ffblk            find_t
  49.     #define ff_name          name
  50. #elif defined(__ZTC__)                              /* Zortech C/C++ */
  51.     #define ffblk             FIND
  52.     #define ff_name           name
  53.     #define ff_attrib         attribute
  54. #endif
  55.  
  56. /*---------------------------------------------------------------------------*/
  57.  
  58. /* function prototypes */
  59. static void activate_demo (void);
  60. static void add_shadow    (void);
  61. static void chg_attr_demo (void);
  62. static void chg_bord_demo (void);
  63. static void chg_wind_attr (int battr,int wattr);
  64. static int  check_date    (char *buf);
  65. static void close_windows (void);
  66. static void confirm_quit  (void);
  67. static void copy_demo     (void);
  68. static void cxlinfo       (void);
  69. static void datademo      (void);
  70. static void directory     (void);
  71. static void display_date  (void);
  72. static void disp_sure_msg (void);
  73. static void display_title (int tpos);
  74. static void do_nothing    (void);
  75. static void error_exit    (int errnum);
  76. static void execute       (void);
  77. static int  find_first    (char *filespec,struct ffblk *ffblk);
  78. static int  find_next     (struct ffblk *ffblk);
  79. static unsigned get_key   (int *done);
  80. static void hide_demo     (void);
  81. static void horz_line     (int wrow,int wcol,int count,int attr);
  82. static void initialize    (void);
  83. static void line_inp_demo (void);
  84. static void main_menu     (void);
  85. static void menudemo      (void);
  86. static void move_bar_down (void);
  87. static void move_demo     (void);
  88. static void move_window   (int nsrow,int nscol);
  89. static void normal_exit   (void);
  90. static void open_back_wind(void);
  91. static void open_stat_wind(void);
  92. static void open_titl_wind(void);
  93. static void os_shell      (void);
  94. static void parse_cmd_line(int argc,char *argv[]);
  95. static void parse_date    (char *buf,int *month,int *day,int *year);
  96. static void pick_compiler (void);
  97. static void pickdemo      (void);
  98. static void popup_demo    (void);
  99. static void pre_help      (void);
  100. static void pre_menu1     (void);
  101. static void pre_menu2     (void);
  102. static void pre_pick1     (void);
  103. static void press_a_key   (int wrow);
  104. static void pulldown_demo (void);
  105. static void quit_window   (void);
  106. static void resize_demo   (void);
  107. static void restore_cursor(void);
  108. static void r_margin      (void);
  109. static void scroll_demo   (void);
  110. static void setup_menu    (void);
  111. static void short_delay   (void);
  112. static void size_window   (int nerow,int necol);
  113. static void text_line_demo(void);
  114. static void title_demo    (void);
  115. static void toggle_block  (void);
  116. static void toggle_yn     (void);
  117. static void update_clock  (void);
  118. static void vert_line     (int wrow,int wcol,int count,int attr);
  119. static void you_selected  (char *str);
  120. static void windemo       (void);
  121.  
  122. /*---------------------------------------------------------------------------*/
  123.  
  124. /* miscellaneous global variables */
  125. static int *savescrn,crow,ccol;
  126. static WINDOW w[10];
  127.  
  128. /*---------------------------------------------------------------------------*/
  129.  
  130. /* fields used in data entry demo */
  131. static char date[7],firstname[16],initial[2],lastname[26],address[41],city[21],
  132.             state[3],zipcode[10],phone[11],compiler[16],amtenc[8],comments[41],
  133.             ssan[10];
  134.  
  135. /*---------------------------------------------------------------------------*/
  136.  
  137. /* months table */
  138. static char *months[]= {
  139.     "January","February","March","April","May","June","July","August",
  140.     "September","October","November","December",NULL
  141. };
  142.  
  143. /* printer ports table */
  144. static char *prn_ports[]= { "PRN","LPT1","LPT2","COM1","COM2",NULL };
  145.  
  146. /* error message table */
  147. static char *error_text[]= {
  148.     NULL,   /* errnum =  0, no error        */
  149.     NULL,   /* errnum == 1, windowing error */
  150.     "Syntax:  CXLDEMO [-switches]\n\n"
  151.         "\t -c = CGA snow elimination\n"
  152.         "\t -b = BIOS screen writing\n"
  153.         "\t -m = force monochrome text attributes",
  154.     "Memory allocation error"
  155. };
  156.  
  157. /* compiler table */
  158. static char *compilers[]=
  159.     { "Microsoft C","Quick C","Turbo C","Zortech C/C++" };
  160.  
  161. /*---------------------------------------------------------------------------*/
  162.  
  163. /* help category numbers */
  164. #define H_GLOBAL    1
  165. #define H_WINDOWING 2
  166. #define H_MENUING   3
  167. #define H_LISTPICK  4
  168. #define H_STRPICK   5
  169. #define H_FILEPICK  6
  170. #define H_DATAENTRY 7
  171. #define H_EDITKEYS  8
  172. #define H_DATE      9
  173. #define H_FIRSTNAME 10
  174. #define H_INITIAL   11
  175. #define H_LASTNAME  12
  176. #define H_CITY      13
  177. #define H_STATE     14
  178. #define H_ZIPCODE   15
  179. #define H_COMPILER  16
  180. #define H_AMOUNT    17
  181. #define H_NUMERIC   18
  182. #define H_PULLDOWN  19
  183. #define H_FILE      20
  184. #define H_EDITING   21
  185. #define H_LOAD      22
  186. #define H_SAVE      23
  187. #define H_RENAME    24
  188. #define H_NEW       25
  189. #define H_DIRECTORY 26
  190. #define H_EXECUTE   27
  191. #define H_OSSHELL   28
  192. #define H_QUIT      29
  193. #define H_SCROLL    30
  194. #define H_CHGATTR   31
  195. #define H_CHGBORD   32
  196. #define H_WINTITLE  33
  197. #define H_RESIZE    34
  198. #define H_TEXTLINE  35
  199. #define H_WINMOVE   36
  200. #define H_WINHIDE   37
  201. #define H_ACTIVATE  38
  202. #define H_WINCOPY   39
  203.  
  204. /*---------------------------------------------------------------------------*/
  205.  
  206. /* miscellaneous defines */
  207. #define SHORT_DELAY 11
  208.  
  209. /*---------------------------------------------------------------------------*/
  210.  
  211. void main(int argc,char *argv[])
  212. {
  213.     initialize();
  214.     parse_cmd_line(argc,argv);
  215.     open_back_wind();
  216.     open_stat_wind();
  217.     open_titl_wind();
  218.     main_menu();
  219.     normal_exit();
  220. }
  221.  
  222. /*---------------------------------------------------------------------------*/
  223.  
  224. static void activate_demo(void)
  225. {
  226.     register int i;
  227.  
  228.     if((w[5]=wopen(9,44,22,78,1,LCYAN|_CYAN,WHITE|_CYAN))==0) error_exit(1);
  229.     whelpcat(H_ACTIVATE);
  230.     wputs("\n  CXL's wactiv() is used to"
  231.           "\n  activate a window, making"
  232.           "\n  it availa